window.addEventListener("load", function () {
	// 点击模态框中的Tab按钮,对应按钮要激活,显示对应的form表单
	tabChange("#loginModalTab a", "active", "#loginModal form", "on");

	$("#loginModal form:nth-child(3)").addEventListener("submit", function (e) {
		// 判断用户名大于6位
		if ($("#loginUser input").value.length < 6) {
			$("#loginUser").style.borderBottom = "1px solid red";
			$("#loginUser input").nextElementSibling.textContent =
				"用户名至少6位以上";
			$("#loginUser input").nextElementSibling.style.color = "red";
			e.preventDefault();
		} else {
			$("#loginUser").style.borderBottom = "1px solid #e7e7e7";
			$("#loginUser input").nextElementSibling.textContent = "";
		}
		// 密码
		if (
			$("#loginPwd input").value.length < 9 ||
			$("#loginPwd input").value.length > 16
		) {
			$("#loginPwd").style.borderBottom = "1px  solid red";
			$("#loginPwd input").nextElementSibling.textContent = "密码9~16位";
			$("#loginPwd input").nextElementSibling.style.color = "red";
			e.preventDefault();
		} else {
			$("#loginPwd").style.borderBottom = "1px  solid #e7e7e7";
			$("#loginPwd input").nextElementSibling.textContent = "";
		}
	});
});
